home *** CD-ROM | disk | FTP | other *** search
- /*
- ** This routines were only modified by me.
- ** I forgot the name of the author, but it was public domain.
- */
-
- #include <exec/types.h>
- #include <proto/graphics.h>
- #include <proto/intuition.h>
- #include <graphics/modeid.h>
- #include <graphics/display.h>
- #include <graphics/displayinfo.h>
- #include <proto/asl.h>
-
- #include <stdlib.h>
- #include <stdio.h>
-
- extern struct Library ASLBase;
-
- #define MAX_HEIGHT 20000
- #define MAX_WIDTH 20000
- ULONG MIN_DEPTH;
- #define MAX_DEPTH 32
- BOOL DD;
-
- int DEFAULT_WIDTH, DEFAULT_HEIGHT, MINIMUM_WIDTH, MINIMUM_HEIGHT;
-
- __asm __saveds BOOL ScreenModeHook(register __a1 ULONG modeid)
- {
- /*
- ** try to filter EHB out, but does not work.
- */
- struct DisplayInfo disinfo;
-
- if(DD == FALSE)
- {
- if(GetDisplayInfoData(NULL,(UBYTE*)&disinfo,sizeof(struct DisplayInfo),DTAG_DIMS,modeid) >= sizeof(struct DisplayInfo))
- {
- if((disinfo.PropertyFlags && DIPF_IS_EXTRAHALFBRITE) &&
- (disinfo.PropertyFlags && DIPF_IS_HAM)) return FALSE;
- }
- else
- {
- return TRUE;
- }
- }
- else
- {
- return TRUE;
- }
- }
-
- int GetScreenMode (ULONG *modeID, int *height, int *width , int *autoscroll,
- int *depth,int M_W, int M_H, ULONG pfl)
- {
- int
- rslt,
- mode_width = *width ,
- mode_height = *height ;
- struct Hook
- ScreenReqHook;
- struct ScreenModeRequester
- *screenReq;
-
- MINIMUM_WIDTH = M_W;
- DEFAULT_WIDTH = M_W;
- MINIMUM_HEIGHT = M_H;
- DEFAULT_HEIGHT = M_H;
-
- if(*depth < 0)
- {
- DD = FALSE;
- MIN_DEPTH = -1*(*depth);
- }
- else
- {
- DD = TRUE;
- MIN_DEPTH = (*depth);
- }
-
- ScreenReqHook.h_Data = NULL;
- ScreenReqHook.h_Entry = (ULONG (*)()) ScreenModeHook;
- ScreenReqHook.h_SubEntry = NULL;
-
- screenReq = (struct ScreenModeRequester *) AllocAslRequestTags (ASL_ScreenModeRequest,
- /*
- ** initial conditions
- */
- ASLSM_InitialDisplayID, *modeID,
- ASLSM_InitialDisplayWidth, DEFAULT_WIDTH,
- ASLSM_InitialDisplayHeight, DEFAULT_HEIGHT,
- ASLSM_InitialOverscanType , NULL,
- ASLSM_InitialDisplayWidth, MAX_DEPTH,
- /*
- ** setup stuff
- */
- ASLSM_SleepWindow, TRUE,
- ASLSM_TitleText, "POVRay Render Screen",
- ASLSM_MinWidth, MINIMUM_WIDTH,
- ASLSM_MinHeight, MINIMUM_HEIGHT,
- ASLSM_MinDepth, MIN_DEPTH,
- ASLSM_MaxDepth, MAX_DEPTH,
- ASLSM_PropertyFlags, pfl,
- ASLSM_FilterFunc, &ScreenReqHook,
- /*
- ** what can the user specify
- */
- ASLSM_DoWidth, TRUE,
- ASLSM_DoHeight, TRUE,
- ASLSM_DoAutoScroll, TRUE,
- ASLSM_DoDepth, DD,
- TAG_DONE);
-
- if (!screenReq)
- {
- fprintf(stderr,"Error: Failed to allocate ScreenModeRequester!\n");
- exit(20);
- }
-
- if (AslRequest (screenReq, NULL) == FALSE)
- {
- fprintf(stderr,"Error: Failed to open Asl Screenmode Requester!\n");
- rslt = 0;
- }
- else
- {
- *modeID = screenReq->sm_DisplayID;
- *height = screenReq->sm_DisplayHeight;
- *width = screenReq->sm_DisplayWidth;
- *depth = screenReq->sm_DisplayDepth;
- *autoscroll = screenReq->sm_AutoScroll;
- rslt = 1;
- }
-
- FreeAslRequest (screenReq);
-
- return rslt;
- }
-